package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import utilClasses.uMapa;

public class daoAndrVoz {
	public static String  noveKoord(String x,String y, String id)
	{
		try {
			Connection c=daoKonekcija.dajKonekciju();
			PreparedStatement ps = c.prepareStatement("UPDATE vozilo set GSirina=?,GDuzina=? WHERE idVozilo=?;");
			ps.setString(1, y);
			ps.setString(2, x);
			ps.setString(3, id);
			ps.executeUpdate();
			ps.close();
			c.close();
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "moze";
	}
	public static uMapa dajkoord(String id) throws SQLException
	{
		uMapa rez = new uMapa();
		Connection c = null;
		try {
			c=daoKonekcija.dajKonekciju();
			PreparedStatement ps = c.prepareStatement("Select GSirina,GDuzina FROM vozilo WHERE idVozilo=?");
			ps.setString(1,id);
			ResultSet rs = ps.executeQuery();
			rs.next();
			rez.setId(id);
			rez.setLgt(rs.getString(2));
			rez.setLat(rs.getString(1));
			rs.close();
			ps.close();
			c.close();
			return rez;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			if(c!=null) c.close();
			return rez;
		}
	}
	
}
